<template>
  <div>
    <div class="goods-item-wap" @click="GoodSdetails(goods)">
      <img :src="goods.img" alt="" />
      <div class="sale" v-if="saleShow">
        <span>已售{{ goods.sale }}件</span>
      </div>
    </div>
    <!-- 商品描述区域 -->
    <div class="goods-info">
      <p class="title">
        {{ goods.title }}
      </p>
      <div class="footer">
        <span class="price" :style="{ color: color }">￥{{ goods.price }}</span>
        <span class="collect">{{ goods.cfav }}</span>
        <img src="../assets/image/cate/collect.png" alt="" />
      </div>
      <div class="bottom" v-if="bottomShow">
        <span>立即购买</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goods: {
      type: Object,
      default: {},
    },
    // 是否显示已售
    saleShow: {
      type: Boolean,
      default: true,
    },
    color: {
      type: String,
      default: "#ff5777",
    },
    bottomShow: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    GoodSdetails(item) {
      this.$router.push({
        path: "/goodsdetails",
        query: {
          id: item.tradeItemId,
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.goods-item-wap {
  height: 177.5px;
  position: relative;
  width: 100%;
  background: #e5e5e5 !important;
  overflow: hidden;
  img {
    width: 100%;
    // height: 100%;
    object-fit: cover;
    border-radius: 3px;
    border: none;
    vertical-align: middle;
  }
  .sale {
    position: absolute;
    left: 0;
    bottom: 5px;
    z-index: 999;
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    background: url(../assets/image/cate/bg.png) no-repeat left center;
    background-size: 100%;
    color: #fff;

    span {
      padding: 0 8px;
    }
  }
}
.goods-info {
  padding: 5px 6px;
  overflow: hidden;
  background-color: #fff;
  .title {
    font-size: 12px;
    line-height: 16px;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }

  .footer {
    display: flex;
    justify-content: space-between;

    .price {
      flex: 1;
      //   color: ;
      font-weight: bold;
      font-size: 15px;
    }

    .collect {
      font-size: 12px;
      color: #999999;
      margin-right: 2px;
    }

    img {
      width: 14px;
      height: 14px;
      margin-top: -2px;
    }
  }
  .bottom {
    width: 100%;
    height: 25px;
    line-height: 25px;
    font-size: 14px;
    text-align: center;
    color: #fff;
    background-color: #ff5777;
    margin-top: 10px;
    border-radius: 3px;
  }
}
</style>